package com.gzhryc.test.kafka;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


import com.gzhryc.common.kafka.KafkaConsumerFactory;
import com.gzhryc.common.kafka.consumer.SingleKafkaConsumer;
import com.gzhryc.test.kafka.impl.SingleConsumerEventLlistener;

public class KafkaConsumerMain {

	public static void main(String[] args) throws IOException, InterruptedException {

        //  配置信息，主要在程序运行开始的时候就必须加载
        /*============================================================ */

        Properties properties = new Properties() ;
        InputStream resourceAsStream = KafkaConsumerMain.class.getClassLoader().getResourceAsStream("consumer.properties");
        properties.load(resourceAsStream) ;
        //  接受消息，会一直运行 , 要在consumerFactory进行加载配置文件
        KafkaConsumerFactory consumerFactory = KafkaConsumerFactory.self() ;
        consumerFactory.initial(properties) ;

        /* ===================================================== */
        KafkaConsumerFactory.self().addConsumer(new SingleKafkaConsumer("orderException",new SingleConsumerEventLlistener())) ;

    }
}
